package com.sxran.im.handler;

import com.google.common.collect.Lists;
import com.sxran.im.bean.ImException;
import com.sxran.im.controller.ImController;
import com.sxran.im.dao.ImGroupMapper;
import com.sxran.im.info.ImGroup;
import com.sxran.im.service.UserGroupService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
@Slf4j
@Service
public class ExitGroupCmdHandler extends AbstractCmdHandler<ImGroup>{

    @Resource
    private UserGroupService userGroupService;

    @Override
    public Object doBeanService(ImGroup json) {
        String groupId = json.getGroupId();
        String curUserId = ImController.getCurUserId();
        userGroupService.removeUser(groupId,Lists.newArrayList(curUserId));
        return json;
    }
}
